﻿
using JSC.Portal.Entities.Interfaces;
namespace JSC.Portal.Entities
{
    /// <summary>
    /// Base class for permission related association objects.
    /// </summary>
    public abstract class Permission : BaseEntity
    {
        private Role _role;

        /// <summary>
        /// Protected constructor
        /// </summary>
        protected Permission()
            : base()
        {
            ViewAllowed = false;
            EditAllowed = false;
        }

        /// <summary>
        /// Property ViewAllowed (bool)
        /// </summary>
        public bool ViewAllowed
        {
            get;
            set;
        }

        /// <summary>
        /// Property EditAllowed (bool)
        /// </summary>
        public bool EditAllowed
        {
            get;
            set;
        }

        /// <summary>
        /// Property Role (Role)
        /// </summary>
        public Role Role
        {
            get { return _role; }
            set 
            {
                if (value != null)
                    RoleId = value.Id;
                _role = value; 
            }
        }

        public int RoleId
        {
            get;
            private set;
        }
    }
}
